package com.qire.manhua.dal.service;

import com.qire.antsbinder.dal.DataService;
import com.qire.antsbinder.dal.annotation.StrategyAnnotation;
import com.qire.common.constant.Url;
import com.qire.common.dal.WarehouseFactory;
import com.qire.common.model.entity.UserEntity;
import com.qire.common.utils.ToastHelper;
import com.qire.common.widget.snackbar.Prompt;
import com.qire.manhua.dal.IUserDataDAL;
import com.qire.manhua.model.vo.EvaluationResponseVO;
import com.qire.manhua.model.vo.OkResponseVO;

public class SystemSetupDataService extends DataService {

    private IUserDataDAL userDataDAL = WarehouseFactory.create(this, IUserDataDAL.class);

    private boolean enableAutoPay;

    /**
     * 切换自动购买状态
     * @param enableAutoPay true 启用 false 禁用
     */
    public void toggleAutoPay(boolean enableAutoPay) {
        this.enableAutoPay = enableAutoPay;
        userDataDAL.toggleAutoPay(enableAutoPay);
    }
    @StrategyAnnotation(event = Url.v3_mySettingAutoPay)
    public void toggleAutoBuyCallback(OkResponseVO dataVO, boolean isCache) {
        ToastHelper.showSnackBar(dataVO.ok, Prompt.SUCCESS);
        UserEntity.self.setAutoPay(enableAutoPay);
    }

    public void markEvaluation() {
        userDataDAL.markEvaluation();
    }
    @StrategyAnnotation(event = Url.v3_myEvaluation)
    public void markEvaluationCallback(EvaluationResponseVO evaluation, boolean isCache){
//        bindingView.userLayout.bean.setText(evaluation.getToday_bean() + "");
    }

}
